cmake_minimum_required(VERSION 3.10)

project(common)

aux_source_directory(./src SRC)

#include_directories
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${CMAKE_INCLUDE_OUTPUT_DIRECTORY}/logger)

link_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib/${ARCH})

#add_executable(common ${SRC}) # 生成可执行文件
#add_library(common STATIC ${SRC}) # 生成静态库
add_library(common SHARED ${SRC}) # 生成动态库或共享库
# SET_TARGET_PROPERTIES(common PROPERTIES VERSION 1.0.0 SOVERSION 1)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} libEasyLogger.so)
#TARGET_LINK_LIBRARIES(common liblogger.so libcrypto.so libssl.so libmosquitto.so libsysconfig.so libyaml-cpp.so libcjson.so)

install(TARGETS ${PROJECT_NAME}  LIBRARY DESTINATION ${CMAKE_LIBRARY_PATH})
        

add_custom_command(TARGET  ${PROJECT_NAME}
        POST_BUILD
        COMMAND echo "${PROJECT_NAME} manager builded finished."
        COMMAND ${CMAKE_COMPILER_STRIP} "$<TARGET_FILE:${PROJECT_NAME}>"
        COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/include/common.h" ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}/common.h
        #  COMMENT  "db manager is install finished"
)